import { docs } from '@/.source';
import { loader } from 'fumadocs-core/source';
import { createElement } from 'react';
import { icons } from 'lucide-react';
import { DocsPage } from 'fumadocs-ui/page';
import * as FcIcons from 'react-icons/fc';
import * as FaIcons from 'react-icons/fa';

// 合并所有图标
const allIcons = {
  ...icons,
  ...FcIcons,
  ...FaIcons
};

// See https://fumadocs.vercel.app/docs/headless/source-api for more info
export const source = loader({
  // it assigns a URL to your pages
  baseUrl: '/docs',
  source: docs.toFumadocsSource(),

  icon(icon) {
    if (!icon) {
      // You may set a default icon
      return;
    }

    if (icon in allIcons) return createElement(allIcons[icon as keyof typeof allIcons]);
  },
});
